<?php

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$json = new stdClass();

$upload_path = trim($_POST['path'], '/'); //nhan lai duong dan upload de xoa anh
$filename = $_POST['filename'];
$fid = intval($_POST['id']);
if(unlink($upload_path . '/' . $filename))
{
    $json->status = 'success';
    if ($fid != -1) {
        //xoa anh trong DB
        $query = 'DELETE FROM {files} WHERE fid = %d';
        db_query($query, $fid);
    }
}
else
{
    $json->status = 'error';
}
echo json_encode($json);
unset ($json);